From: Jeroen van der Heijden Date: Fri, 5 Oct 2018 16:12:32 +0000 (+0200) Subject: Work on integration testing in docker X-Git-Tag: archive/raspbian/2.0.44-1+rpi1~1^2~3^2~8^2~34 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=46adbfb635d44238f8a73d76b2a297652e42f966;p=siridb-server.git Work on integration testing in docker --- diff --git a/itest/Dockerfile b/itest/Dockerfile new file mode 100644 index 00000000..21b0473d --- /dev/null +++ b/itest/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:18.04 +COPY ./main.c ./main.c +COPY ./src/ ./src/ +COPY ./include/ ./include/ +COPY ./Release/ ./Release/ +RUN apt-get update && \ + apt-get install -y \ + libcleri-dev \ + libuv1-dev \ + libpcre2-dev \ + uuid-dev \ + build-essential +RUN cd ./Release && \ + make clean && \ + make + +FROM python +RUN apt-get update && \ + apt-get install -y valgrind +COPY --from=0 ./Release/siridb-server /Release/siridb-server +COPY ./itest/ /itest/ +WORKDIR /itest +RUN pip install -r requirements.txt +CMD [ "python", "test_select.py" ] \ No newline at end of file diff --git a/itest/requirements.txt b/itest/requirements.txt new file mode 100644 index 00000000..f44e6797 --- /dev/null +++ b/itest/requirements.txt @@ -0,0 +1,2 @@ +siridb-connector +psutil diff --git a/itest/test_select.py b/itest/test_select.py index 1a9f5c61..3d9df9dc 100644 --- a/itest/test_select.py +++ b/itest/test_select.py @@ -486,12 +486,13 @@ class TestSelect(TestBase): self.client0.close() - return False + # return False if __name__ == '__main__': SiriDB.LOG_LEVEL = 'CRITICAL' Server.HOLD_TERM = True Server.MEM_CHECK = True + Server.TERMINAL = 'XTERM' Server.BUILDTYPE = 'Debug' run_test(TestSelect()) diff --git a/itest/testing/constants.py b/itest/testing/constants.py index 14223bcc..e578923e 100644 --- a/itest/testing/constants.py +++ b/itest/testing/constants.py @@ -2,11 +2,16 @@ BUILDTYPE = 'Debug' TEST_DIR = './testdir' SIRIDBC = '../{BUILDTYPE}/siridb-server' ADMIN = '/usr/local/bin/siridb-admin' -VALGRIND = 'valgrind' + \ - ' --tool=memcheck' + \ - ' --leak-check=full' + \ - ' --show-leak-kinds=all' + \ - ' --track-origins=yes' + \ +VALGRIND = 'valgrind' \ + ' --tool=memcheck' \ + ' --error-exitcode=1' \ + ' --leak-check=full' \ + ' --show-leak-kinds=all' \ + ' --track-origins=yes' \ ' -v ' -VALGRIND = 'valgrind --tool=memcheck ' +VALGRIND = 'valgrind' \ + ' --tool=memcheck' \ + ' --error-exitcode=1' \ + ' --leak-check=full ' + MAX_OPEN_FILES = 512 # Default value is 32768 but with valgrind 512 is max diff --git a/itest/testing/server.py b/itest/testing/server.py index a629449e..ca21e46c 100644 --- a/itest/testing/server.py +++ b/itest/testing/server.py @@ -25,7 +25,7 @@ class Server: BUILDTYPE = BUILDTYPE SERVER_ADDRESS = '%HOSTNAME' IP_SUPPORT = 'ALL' - USE_XFCE4 = False + TERMINAL = None # one of [ 'XTERM', 'XFCE4_TERMINAL', None ] BIND_CLIENT_ADDRESS = "::" BIND_SERVER_ADDRESS = "::" @@ -107,7 +107,7 @@ class Server: async def start(self, sleep=None): prev = self._get_pid_set() - if self.USE_XFCE4: + if self.TERMINAL == 'XFCE4_TERMINAL': rc = subprocess.Popen( 'xfce4-terminal -e "{}{} --config {} --log-colorized"' ' --title {} --geometry={}{}' @@ -118,7 +118,7 @@ class Server: self.GEOMETRY, ' -H' if self.HOLD_TERM else ''), shell=True) - else: + elif self.TERMINAL == 'XTERM': rc = subprocess.Popen( 'xterm {}-title {} -geometry {} -e "{}{} --config {}"' .format('-hold ' if self.HOLD_TERM else '', @@ -128,6 +128,18 @@ class Server: SIRIDBC.format(BUILDTYPE=self.BUILDTYPE), self.cfgfile), shell=True) + else: + with open(f'{self.name}-err.log', 'a') as err: + with open(f'testdir/{self.name}-out.log', 'a') as out: + rc = subprocess.Popen( + '{}{} --config {}' + .format(VALGRIND if self.MEM_CHECK else '', + SIRIDBC.format(BUILDTYPE=self.BUILDTYPE), + self.cfgfile), + stderr=err, + stdout=out, + shell=True) + self.assertEqual(rc, 0) await asyncio.sleep(5) diff --git a/itest/testing/testbase.py b/itest/testing/testbase.py index d9a7204a..dfba3d2b 100644 --- a/itest/testing/testbase.py +++ b/itest/testing/testbase.py @@ -27,7 +27,7 @@ def default_test_setup(nservers=1, **kwargs): close = await func(self) - if close or close is None: + if close or close is None or Server.TERMINAL is None: for server in self.servers: result = await server.stop() self.assertTrue( diff --git a/test/test_siridb/test_siridb.c b/test/test_siridb/test_siridb.c index aa1a1989..40771c77 100644 --- a/test/test_siridb/test_siridb.c +++ b/test/test_siridb/test_siridb.c @@ -113,8 +113,6 @@ static int test_series_ensure_type(void) int main() { - - return ( test_series_ensure_type() || 0